package com.liming.service;

import java.util.List;

import com.liming.dao.CartGoodsdao;
import com.liming.item.CartGoodItems;
import com.liming.model.CartGoods;

public class CartGoodsService {

	CartGoodsdao cartGoodsdao = new CartGoodsdao();
	
	public int changeQuantity(CartGoods cartGoods) {
		
		int goodsnum = cartGoods.getGoodsnum();
		if(goodsnum==-1)
		{
			return cartGoodsdao.deleteGoods(cartGoods);
		}
		else {
			return cartGoodsdao.changeQuantity(cartGoods);
		}
	
	}

	public List<CartGoods> initializeCart(int userid) {
		
		return cartGoodsdao.initializeCart(userid);
		
	}

	public Boolean putInCart(CartGoods cartGoods) {
		int count = cartGoodsdao.putInCart(cartGoods);
		if(count==0) {
			return false;
		}
		else{
			return true;
		}
	}

	public List<CartGoodItems> getAllGoods(int userid) {
		
		return cartGoodsdao.getAllGoods(userid);
	}
	
}
